@echo off
setlocal enabledelayedexpansion

echo ================================================
echo System Environment Check
echo ================================================
echo.

:: Check admin rights
net session >nul 2>&1
if %errorlevel% equ 0 (
    echo [OK] Administrator rights: YES
) else (
    echo [ERROR] Administrator rights: NO
)

:: Check Windows version
ver | find "Windows 10" >nul
if %errorlevel% equ 0 (
    echo [OK] Windows version: Windows 10
) else (
    ver | find "Windows 11" >nul
    if %errorlevel% equ 0 (
        echo [OK] Windows version: Windows 11
    ) else (
        echo [WARNING] Windows version: Unknown
    )
)

:: Check Git
where git >nul 2>&1
if %errorlevel% equ 0 (
    for /f "tokens=*" %%i in ('git --version') do echo [OK] Git: %%i
) else (
    echo [MISSING] Git: Not found
)

:: Check Docker
where docker >nul 2>&1
if %errorlevel% equ 0 (
    for /f "tokens=*" %%i in ('docker --version') do echo [OK] Docker: %%i
    
    :: Check Docker service
    sc query "com.docker.service" | find "RUNNING" >nul
    if %errorlevel% equ 0 (
        echo [OK] Docker service: Running
    ) else (
        echo [WARNING] Docker service: Not running
    )
) else (
    echo [MISSING] Docker: Not found
)

:: Check Java
where java >nul 2>&1
if %errorlevel% equ 0 (
    for /f "tokens=*" %%i in ('java -version 2^>^&1 ^| find "version"') do echo [OK] Java: %%i
) else (
    echo [MISSING] Java: Not found
)

:: Check Node.js
where node >nul 2>&1
if %errorlevel% equ 0 (
    for /f "tokens=*" %%i in ('node --version') do echo [OK] Node.js: %%i
) else (
    echo [MISSING] Node.js: Not found
)

:: Check ports
echo.
echo Port Status:
netstat -an | find ":3000 " | find "LISTEN" >nul
if %errorlevel% equ 0 (
    echo [OCCUPIED] Port 3000
) else (
    echo [AVAILABLE] Port 3000
)

netstat -an | find ":8080 " | find "LISTEN" >nul
if %errorlevel% equ 0 (
    echo [OCCUPIED] Port 8080
) else (
    echo [AVAILABLE] Port 8080
)

:: Check project files
echo.
echo Project Files:
if exist "docker-compose.yml" (
    echo [FOUND] docker-compose.yml
) else (
    echo [MISSING] docker-compose.yml
)

if exist "pom.xml" (
    echo [FOUND] pom.xml (backend)
) else (
    echo [MISSING] pom.xml
)

if exist "frontend\package.json" (
    echo [FOUND] package.json (frontend)
) else (
    echo [MISSING] frontend\package.json
)

echo.
echo ================================================
echo Check complete - press any key to continue
echo ================================================
pause